import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

//引入icon
import './assets/font/iconfont.css'



//引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import { Loading } from 'element-ui';

//引入axios
import axios from 'axios';
Vue.prototype.axios=axios
axios.defaults.baseURL = "http://121.41.51.231:5000/api/private/v1/";

//axios拦截器
//发送请求之前触发
axios.interceptors.request.use(config=>{
  config.headers.Authorization=sessionStorage.getItem("token");
  //设置等待框
  Loading.service();
  return config;
})
//服务器响应之后触发
axios.interceptors.response.use(config=>{
  Loading.service().close();
  if (config.data.meta.status !=200) {
    router.push("/Login")
  }
  return config;
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
